<?php
require('src/Producto.class.php');
$id = (isset($_GET['id'])) ? $_GET['id']:0;
$codigo = "";
$nombre = "";
$descri = "";
$presNo = "";
$presId = 0;
$preUni = "";
$tiempV = "";
$holgur = "";

if($id!=0){    
    $obj    = new Producto();
    $res    = $obj->getConsulta($id, 2);
    if( $row = mysql_fetch_array( $res ) ){
        $codigo = $row["pte_codigo"];
        $nombre = $row["pte_nombre"];
        $descri = $row["pte_descripcion"];
        $presId = $row["pre_id"];
        $presNo = $row["pre_nombre"];
        $preUni = $row["pte_preciounitario"];
    }
}
?>
<script>
$("#presP").autocomplete({
    source: "src/producto.php?modo="+5,
    minLength: 2,
    select: function(event, ui) {
             $("#presId").val(ui.item.id);
    }
});
</script>
<form id="formID" class="z-form " method="post" action="">
    <div class="row">
        <div class="cell">
            <label><span class="required">*</span>Codigo</label>
            <input name="codigo" class="validate[required, minSize[3],maxSize[10], custom[integer]] text-input" type="text" id="codigo" value="<?php echo $codigo; ?>" />
        </div>
        <div class="cell">
            <label><span class="required">*</span>Nombre</label>
            <input name="nombre" class="validate[required, minSize[3],maxSize[45]] text-input meddium" type="text"  id="nombre" value="<?php echo $nombre; ?>"/>
        </div> 
    </div>
    <div class="row">
        <div class="cell">
            <label for="presP"><span class="required">*</span>Presentaci&oacute;n Producto </label>
            <input type="text" id="presP" name="presP" class="validate[required] text-input meddium" value="<? echo $presNo; ?>" />
            <input type='hidden' id="presId"  name="presId" value='<? echo $presId; ?>' />            
        </div>
        <div class="cell">
            <label><span class="required">*</span>Precio Unitario</label>
            <input name="preUni" class="validate[required] text-input" type="text" id="preUni" value="<?php echo $preUni; ?>" />
        </div>               
    </div>
    <div class="clear"></div>
    <div class="row">
        <div class="cell">
            <label>Descripci&oacute;n</label>
            <textarea rows="2" cols="20" class="full" name="descri" id="descri"><?php echo $descri; ?></textarea>
        </div>
    </div>    
</form>

